package com.geline.easytrans.enums;

import com.geline.easytrans.annotation.DictType;
import com.geline.easytrans.dict.IDict;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 性别
 * @author: mengxin
 * @date: 2022/5/10 18:03
 */
@DictType(value = "sys_sex", label = "性别")
@AllArgsConstructor
@Getter
public enum SexEnum implements IDict {
    MAN("M","男"),
    FEMALE("F","女"),
    NO("N","未知");

    private String code;
    private String desc;

    public static SexEnum getRealGender(String originalGender) {
        if (null != originalGender && !NO.getCode().equals(originalGender)) {
            return Arrays.asList("m", "男", "1", "male").contains(originalGender.toLowerCase()) ? MAN : FEMALE;
        } else {
            return NO;
        }
    }

    @Override
    public String getLabel() {
        return desc;
    }

    @Override
    public Object getValue() {
        return code;
    }

    @Override
    public Boolean getDefault() {
        return "N".equals(code);
    }
}
